Skip to content

London | 26-ITP-Sep | Russom Gebremeskel | Sprint 1 | Coursework - #1506

Open
russom-g wants to merge 52 commits into
CodeYourFuture:mainfrom
russom-g:coursework/sprint-1-current
Open

russom-g wants to merge 52 commits into
CodeYourFuture:mainfrom
russom-g:coursework/sprint-1-current

Conversation

@russom-g

@russom-g russom-g commented Nov 8, 2026

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Task code

CYF-1071

Changelist

Fix, refactor and implement code. Write test cases for the program.

@cjyuan cjyuan added the Reviewed Volunteer to add when completing a review with trainee action still to take. label Nov 10, 2026
@russom-g russom-g added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 25, 2026
Comment thread Sprint-1/implement/describe-median.js Outdated
try {
return `The median is ${calculateMedian(list)}`;
} catch (error) {
return `Could not calculate a median: calculateMedian requires a non-empty array: ${error.message}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exact sentence does this return when calculateMedian throws the empty-array error, compared with the example in the acceptance criteria?

To "like" or "dislike" this comment, please follow this link

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Could not calculate a median: calculateMedian requires a non-empty array"

Comment thread Sprint-1/implement/sum.test.js Outdated
expect(() => sum([null])).toThrow(
new Error("sum requires an array of numbers")
);
expect(() => sum([3])).toThrow(new Error("sum requires an array of numbers"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These assertions expect sum([3]) to throw, so the suite fails for a valid array of numbers. The purported non-array test repeats array inputs instead of checking a non-array.

To "like" or "dislike" this comment, please follow this link

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}
total = total + item;
}
return Number(total.toFixed(2)) / list.length;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens to the mean of values with more than two decimal places when the total is rounded before dividing?

To "like" or "dislike" this comment, please follow this link

test("given [1, 2, 3], returns The median is 2", () => {
const list = [1, 2, 3];
const result = describeMedian(list);
expect(describeMedian(list)).toEqual(result);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What incorrect sentence would either of these assertions catch if describeMedian returned the wrong result?

To "like" or "dislike" this comment, please follow this link

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Could not calculate a median: calculateMedian requires a non-empty array"

Comment on lines +44 to +45
const list = [];
const result = describeMedian(list);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this test pass a non-array value to describeMedian?

To "like" or "dislike" this comment, please follow this link

Comment thread Sprint-1/implement/mean.test.js Outdated
// When passed to calculateMean
// Then it should return that number
test("given [6], returns 6", () => {
expect(6).toEqual(6);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What function call is this assertion checking?

To "like" or "dislike" this comment, please follow this link

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calculateMean

test("given an empty array, it returns an empty array", () => {
const list = [];
const result = dedupe(list);
expect(dedupe(list)).toEqual(result);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What output does this test require for an empty list?

To "like" or "dislike" this comment, please follow this link

Comment thread Sprint-1/implement/max.js Outdated
throw new Error("findMax requires an array of numbers");
}

if (!elements.length === 1) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a one-element array, what does !elements.length compare with 1?

To "like" or "dislike" this comment, please follow this link

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong logic. Fixed

@cyf-ai-code-reviewer cyf-ai-code-reviewer Bot added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 25, 2026
@cyf-ai-code-reviewer

Copy link
Copy Markdown

The CYF AI review has left comments. It will only review a PR one time. When you have addressed these comments, please request review again and a volunteer will take a look.

@russom-g russom-g added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 26, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also addressed the comments by AI?

Comment on lines 1 to +6
// Don't change this function.
function calculateMedian(list) {
if (!Array.isArray(list)) {
throw new Error("calculateMedian requires an array of numbers");
throw new Error(
"Could not calculate a median: calculateMedian requires a non-empty array"
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were not supposed to change this function (per instruction on line 1).

What you should do is find a way to reuse the error message in describeMedian() when it catches the error thrown by calculateMedian().

Your previous approach was in the right direction except that it didn't return the expected string.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 27, 2026
@russom-g russom-g added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants